<!DOCTYPE html>
<html>
<head>
    <title>微信安全支付</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"/>
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <link href="/css/wechat/reset.css" rel="stylesheet" type="text/css"/>
    <link href="/css/wechat/style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript">
        var id = '{$smarty.get.id}';

        //调用微信JS api 支付
        function jsApiCall() {
            WeixinJSBridge.invoke(
                'getBrandWCPayRequest',
                    {$jsApiParameters},
                function (res) {
                    WeixinJSBridge.log(res.err_msg);
//                        alert(res.err_code + res.err_desc + res.err_msg);
                    if (res.err_msg == "get_brand_wcpay_request:ok") {
                        alert("微信支付成功!");
                        location.href = 'http://{$_F['http_host']}/Index/msgList';
                    }
                    else {
                        alert('支付失败');
                        //location.href = 'http://{$_F['http_host']}/Index/pay?id=' + id;
                    }
                }
            )
            ;
        }

        function callpay() {
            if (typeof WeixinJSBridge == "undefined") {
                if (document.addEventListener) {
                    document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
                } else if (document.attachEvent) {
                    document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                    document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
                }
            } else {
                jsApiCall();
            }
        }

        callpay();
    </script>
</head>
<body>
<div class="wei-pay">
    <b>￥{$price}元</b>
</div>
<div class="skf-con">
    <ul>
        <li><span>{$name}</span>收款方</li>
        <li><span>{$body}</span>商品名</li>
    </ul>
</div>
<div class="ljpay"><a href="#" onClick="callpay()">立即支付</a></div>
</body>
</html>